from django.db import models

# Create your models here.
class BookInfoManager(models.Manager):
    def create_book(self,title,pub_date):
        # book = self.Model()
        # book.btitle = title
        # book.bpub_date = pub_date
        # book.bread = 0
        # book.bcommet = 0
        # book.isDelete = False
        book = self.create(btitle = title,bpub_date = pub_date,bread = 0,bcommet = 0,isDelete = False)
        return book

    def get_queryset(self):
        return super(BookInfoManager, self).get_queryset().filter(isDelete = False)

class BookInfo(models.Model):
    btitle = models.CharField(max_length = 20)
    bpub_date = models.DateTimeField()
    bread = models.IntegerField(default = 0)
    bcommet = models.IntegerField(default = 0)
    isDelete = models.BooleanField(default = False)
    books = BookInfoManager()

class HeroInfo(models.Model):
    hname = models.CharField(max_length = 20)
    hgender = models.BooleanField(default = True)
    hcontent = models.CharField(max_length = 100)
    isDelete = models.BooleanField(default= False)
    hbook = models.ForeignKey("BookInfo")